<extend name="Common@Base/layout"/>
<block name="body">
    <form id="edit_task_form" name="edit_task_form" method="post" action="/task/index/save">
        <input type="hidden" name="id" value="{$user_task.id}"/>
        <input type="hidden" name="status" value="{$user_task.status}"/>
        <div class="home-main">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="panel panel-default panel-home-table">
                            <div class="modal-header">
                                <h4 class="modal-title" id="batch-title">
                                    <if condition="$user_task.status lt 3">
                                        <if condition="$user_task.task_type eq 1">
                                            编辑加分项信息
                                            <input name="task_type" type="hidden" value="1">
                                            <else/>
                                            编辑任务信息
                                            <input name="task_type" type="hidden" value="0">
                                        </if>
                                        <else/>
                                        <if condition="$user_task.task_type eq 1">
                                            查看加分项信息
                                            <input name="task_type" type="hidden" value="1">
                                            <else/>
                                            查看任务信息
                                            <input name="task_type" type="hidden" value="0">
                                        </if>
                                    </if>
                                </h4>
                            </div>
                            <div class="modal-body">
                                <if condition="$user_task.is_back eq 1">
                                <div class="form-group" >
                                    <label style="color: red">退回原因<span class="text-muted">:</span></label>
                                    <p>{$user_task.back_reason}</p>
                                </div>
                                </if>
                                <div class="form-group">
                                    <label>标题<span class="text-muted">:</span></label>
                                    <p>{$user_task.title}</p>
                                </div>
                                <div class="form-group" syt>
                                    <label>说明<span class="text-muted">:</span></label>
                                    <p>{$user_task.content}</p>
                                </div>

                                <div class="row">
                                    <div class="form-group col-sm-8">
                                        <label>填写内容<span class="text-muted">:</span></label>
                                        <if condition="$user_task.status lt 3">
                                            <textarea name="report_content" class="form-control" style="height:120px">{$user_task.report_content}</textarea>
                                            <else/>
                                            <p>{$user_task.report_content}</p>
                                        </if>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-sm-8">
                                        <label>附件<span class="text-muted">:&nbsp&nbsp</span>
                                            <volist name="annex_list" id="annex">
                                                <span class="text-muted">&nbsp&nbsp
                                                    <a target="_blank" href="{$Think.config.UPLOAD_IMAGE_URL}{$annex.annex_path}">
                                                    {$annex.annex_name}
                                                    </a>
                                                     <if condition="$user_task.status lt 3">
                                                    <a style="padding-left:2px;padding-right:10px" href="javascript:void(0);" class="deleteannex" data-aid="{$annex.id}">×</a>
                                                          </if>
                                                </span>
                                            </volist>
                                        </label>
                                        <if condition="$user_task.status lt 3">
                                            <div id="ossfile">你的浏览器不支持flash,Silverlight或者HTML5！</div>
                                            <br/>

                                            <div id="container">
                                                <a id="selectfiles" href="javascript:void(0);" class='btn'>选择文件</a>
                                                <a id="postfiles" href="javascript:void(0);" class='btn' style="display:none">开始上传</a>
                                            </div>
                                        </if>
                                        <div id="console"></div>
                                    </div>
                                </div>
                                <div class="body-footer">
                                    <if condition="$user_task.status lt 2">
                                        <button type="button" class="btn btn-primary" action-type="draft">保存草稿</button>
                                    </if>
                                    <if condition="$user_task.status lt 3">
                                        <button type="button" class="btn btn-primary" action-type="publish">上报信息</button>
                                    </if>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <form name=theform style="display:none">
        <input type="radio" name="myradio" value="random_name" checked=true/>
    </form>
    <script type="text/javascript" src="/up/lib/plupload-2.1.2/js/plupload.full.min.js"></script>
    <script type="text/javascript" src="/up/upload.js"></script>
    <script>

        $(document).ready(function () {
            $('#nav-task{$task_type}').addClass("active");
            $("#ossfile").delegate("a", "click", function () {
                var r1 = $(this).parent().parent();
                for (var i in uploader.files) {
                    if (uploader.files[i].id == r1.attr('id')) {
                        uploader.files.splice(i, 1)
                    }
                }
                r1.remove();
            });
            $('#edit_task_form button[action-type="draft"]').click(function () {
                $(this).attr("disabled", "true");
            });

            $('[action-type="draft"][type="button"]').click(function () {
                $('#edit_task_form input[name="status"]').val('1');
                $('#edit_task_form').submit();
            });
            $('[action-type="publish"][type="button"]').click(function () {
                alertify.confirm("确定上报此信息?", function () {
                    $('#edit_task_form input[name="status"]').val('2');
                    $('#edit_task_form').submit();
                });

            });

            $('.deleteannex').click(function () {
                var $this = $(this);
                var aid = $(this).data('aid');
                alertify.confirm("确定删除此附件?", function () {
                    $.post('/task/index/deleteannex', 'id=' + aid, function (data) {
                        if (data === "0") {
                            $this.parent().remove()
                        }
                    }).error(function (msg, url, line) {
                        alert(msg.responseText);
                    });
                });
            });
        })

    </script>
</block>